package com.dsh.subscribe.controller;

import com.dsh.model.Result;
import com.dsh.subscribe.entity.HealthCareProgram;
import com.dsh.subscribe.entity.vo.*;
import com.dsh.subscribe.service.HealthCareProgramService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 健康医疗项目(HealthCareProgram)表控制层
 *
 * @author makejava
 * @since 2022-04-29 09:17:36
 */
@Api(tags = "健康醫療項目")
@RestController
@RequestMapping("healthCareProgram")
public class HealthCareProgramController {
    /**
     * 服务对象
     */
    @Resource
    private HealthCareProgramService healthCareProgramService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("通過項目id查健康醫療項目")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "id", value = "健康醫療項目id", required = true, dataType = "int")})
    @GetMapping("selectOne")
    public HealthCareProgramVo selectOne(Integer id) {
        HealthCareProgramVo healthCareProgramVo = healthCareProgramService.queryById(id);
        return healthCareProgramVo;
    }

    @GetMapping("queryAllByLimit")
    @ApiOperation("查全部的健康醫療項目")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "limit", value = "分页大小", required = true, dataType = "int"),
            @ApiImplicitParam(paramType = "query", name = "page", value = "分页数", required = true, dataType = "int")
    })
    public Result queryAllByLimit(String projectName, String typeName, int limit, int page) {
        PageInfo<HealthCareProgram> healthCareProgramPageInfo = healthCareProgramService.queryAllByLimit(projectName, typeName, limit, page);
        return Result.success(healthCareProgramPageInfo, "");
    }

//    @GetMapping("insertHealthCareProgram")
//    @ApiOperation("增加健康醫療項目")
//    public Result insertHealthCareProgram(HealthCareProgramVo healthCareProgramVo) {
//        int i = healthCareProgramService.insertHealthCareProgram(healthCareProgramVo);
//        return Result.success(i, "");
//    }

    /**
     * 更改健康管理的状态
     */
    @ApiOperation("更改健康管理的状态")
    @ApiImplicitParam(paramType = "query", name = "id", value = "健康项目的id", required = true, dataType = "int")
    @PostMapping("updateStatus")
    public Result updateStatus(int id) {
        int i = healthCareProgramService.updateStatus(id);
        return Result.success(i, "");
    }

    /**
     * 健康一级分类
     */
    @ApiOperation("查询健康分类")
    @GetMapping("selectAllType")
    public Result selectAllType() {
        List<HealthType> healthTypes = healthCareProgramService.selectAllType();
        return Result.success(healthTypes,"");
    }
    @ApiOperation("增加项目")
    @PostMapping("insertProgram")
    public Result insertProgram(@RequestBody HealthCareProgramVo healthCareProgramVo){
        int i = healthCareProgramService.insertProgram(healthCareProgramVo);
        return Result.success(i,"");
    }
    @ApiOperation("修改管理项目")
    @PostMapping("update")
    public Result update(HealthCareProgramVo healthCareProgramVo){
        int update = healthCareProgramService.update(healthCareProgramVo);
        return  Result.success(update,"");
    }
    @ApiOperation("查询治疗理疗条数")
    @GetMapping("selectPhysiotherapyCount")
    public  Result selectPhysiotherapyCount(){
        PhysiotherapyCountVo physiotherapyCountVo = healthCareProgramService.selectPhysiotherapyCount();
        return Result.success(physiotherapyCountVo,"");

    }
    @ApiOperation("增加二级分类")
    @PostMapping("insertSonType")
    public Result insertSonType(SonTypeVo sonTypeVo){
        int i = healthCareProgramService.insertSonType(sonTypeVo);
        return Result.success(i,"");
    }
    @ApiOperation("更改二级分类")
    @PostMapping("updateSonType")
    public Result updateSonType(SonTypeVo sonTypeVo){
        int i = healthCareProgramService.updateSonType(sonTypeVo);
        return Result.success(i,"");
    }

    @ApiOperation("增加一级分类")
    @PostMapping("insertType")
    public Result insertType(TypeVo typeVo){
        int i = healthCareProgramService.insertType(typeVo);
        return Result.success(i,"");
    }
    @ApiOperation("更改二级分类")
    @PostMapping("updateType")
    public Result updateType(TypeVo typeVo){
        int i = healthCareProgramService.updateType(typeVo);
        return Result.success(i,"");
    }
}